package com.b511.swpu.cementbackend.controller;

import com.b511.swpu.cementbackend.dto.input.DataAnalysisInputDto;
import com.b511.swpu.cementbackend.dto.input.dataAnalyze.ConsumptionInputDto;
import com.b511.swpu.cementbackend.dto.input.dataAnalyze.WorkWellCountInputDto;
import com.b511.swpu.cementbackend.service.DataAnalysisService;
import com.b511.swpu.cementbackend.util.R;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;

@Api(value = "数据分析", tags = {"数据分析"})
@RestController
@RequestMapping("/dataAnalysis")
public class DataAnalysisController {

    private final DataAnalysisService dataAnalysisService;

    public DataAnalysisController(DataAnalysisService dataAnalysisService) {
        this.dataAnalysisService = dataAnalysisService;
    }

    //获取作业公司
    @GetMapping("/getCementCompany")
    public R getCementCompany(){
        return dataAnalysisService.getCementCompany();
    }

    // 通过 作业公司 和 时间 统计工作量
    @GetMapping("/getDataByCompanyAndTime")
    public R getDataByCompanyAndTime(@RequestParam(value = "cementCompany",required = false) String cementCompany,@RequestParam(value = "work_date",required = false) String work_date,@RequestParam(value = "report_date",required = false) String report_date) {
        return dataAnalysisService.getDataByCompanyAndTime(cementCompany,work_date,report_date);
    }

    // 获取 某作业公司 对应的 区域 列表
    @GetMapping("/getAreaByCompany")
    public R getAreaByCompany(@RequestParam(value = "cementCompany",required = false) String cementCompany) {
        return  dataAnalysisService.getAreaByCompany(cementCompany);
    }

    // 获取 某作业公司，某区域 下的全部 区块
    @GetMapping("/getBlockByArea")
    public R getBlockByArea(@RequestParam(value = "cementCompany",required = false) String cementCompany,
                            @RequestParam(value = "area", required = false) String area){
        return dataAnalysisService.getBlockByArea(cementCompany, area);
    }

    // 查询 某区域，某区块 下的 全部油田
    @GetMapping("/getOilfieldByAreaAndBlock")
    public R getOilfieldByAreaAndBlock(@RequestParam(value = "cementCompany",required = false) String cementCompany,
                                       @RequestParam(value = "area", required = false) String area,
                                       @RequestParam(value = "block", required = false) String block){
        return dataAnalysisService.getOilfiledByAreaAndBlock(cementCompany, area, block);
    }

    // 按照任意组合的条件查询 材料消耗 + 附件消耗
    @GetMapping("/getConsumptionByCondition")
    public R getConsumptionByCondition(@ModelAttribute ConsumptionInputDto consumptionInputDto){
        return dataAnalysisService.getMaterialConsumptionByCondition(consumptionInputDto);
    }

    // 按照任意组合的条件查询 材料消耗 + 附件消耗
    @GetMapping("/getWorkWellByCondition")
    public R getWorkWellByCondition(@ModelAttribute WorkWellCountInputDto workWellCountInputDto){
        return dataAnalysisService.getWorkWellInfoByCondition(workWellCountInputDto);
    }

}
